package com.example.demo.controller;
/*
 * 李洲 2020030654A1213
 * 2024.05.24
 */
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/users")
public class UserController {

    // 处理 GET 请求，返回用户列表
    @GetMapping
    public String getAllUsers() {
        return "Returning all users";
    }

    // 处理 GET 请求，根据用户 ID 返回特定用户
    @GetMapping("/{id}")
    public String getUserById(@PathVariable String id) {
        return "Returning user with ID: " + id;
    }

    // 处理 POST 请求，创建新用户
    @PostMapping
    public String createUser(@RequestBody String user) {
        return "Creating user: " + user;
    }

    // 处理 PUT 请求，根据用户 ID 更新用户
    @PutMapping("/{id}")
    public String updateUser(@PathVariable String id, @RequestBody String user) {
        return "Updating user with ID: " + id + " to: " + user;
    }

    // 处理 DELETE 请求，根据用户 ID 删除用户
    @DeleteMapping("/{id}")
    public String deleteUser(@PathVariable String id) {
        return "Deleting user with ID: " + id;
    }
}
